#pragma once
#include <sstream>
#include <fstream>
#include <iomanip>
#include "Utility.h"
using namespace Utility;

/************************************************************************/
/*FileWriter: this class is used as parent class                                                              */
/************************************************************************/
class FileWriter
{
public:
	FileWriter(std::string fileName);
	~FileWriter(void);

	bool			openFile();

	//interface for subclass implementation
	virtual	void	writeFileHeader() = 0;

	virtual void	writeStringToFile(std::string dataStr);

	void			writeStringToFile(std::string dataStr, int setWidth);

	void			flushAndNewLine();

protected:
	std::string		mFileName;
	std::ofstream	mFileOutStream;
};

/************************************************************************/
/*DataFileWriter: this class is used to record data into file                                                                    */
/************************************************************************/
class DataFileWriter : public FileWriter
{
public:
	DataFileWriter(std::string fileName);
	~DataFileWriter();
	
	virtual void	writeFileHeader();
};

/************************************************************************/
/*LogFileWriter: used to record some errors during com port connecting                                                                      */
/************************************************************************/
class LogFileWriter : public FileWriter
{
public:
	LogFileWriter(std::string fileName);
	~LogFileWriter();

	virtual void	writeFileHeader();
	virtual void	writeStringToFile(std::string dataStr);

};